*** Time-seies file

* Load anes_timeseries_cdf_stata_20220916 from https://electionstudies.org/.

* presidential party choice VCF0704
* abortion VCF0838
* gender VCF0104
* age group VCF0102
* race VCF0106
* education VCF0110
* family income VCF0114
* ecnoomy better/worse VCF0870


gen rep_vote =1 if VCF0704 ==2
replace rep_vote =0 if VCF0704==1

gen pro_abortion = 1 if VCF0838==4
replace pro_abortion= 0 if VCF0838==1
replace pro_abortion= 0 if VCF0838==2
replace pro_abortion= 0 if VCF0838==3

replace VCF0111 =. if VCF0111==0

gen pro_abortion_graph = 1 if VCF0838==4
replace pro_abortion_graph= 0 if VCF0838==1
replace pro_abortion_graph= 0 if VCF0838==2
replace pro_abortion_graph= 0 if VCF0838==3
replace pro_abortion_graph= 0 if VCF0838==9

global Y "pro_abortion_graph"

* Figure 1

preserve
collapse (mean) $Y, by(VCF0004)
twoway (line pro_abortion VCF0004) if VCF0004>1979
restore

* Obstain estimates in figure 2

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==1980, vce(robust)

estimates store A

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==1984, vce(robust)

estimates store B

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==1988, vce(robust)

estimates store C

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==1992, vce(robust)

estimates store D

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==1996, vce(robust)

estimates store E

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==2000, vce(robust)

estimates store F

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==2004, vce(robust)

estimates store G

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==2008, vce(robust)

estimates store H

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==2012, vce(robust)

estimates store I

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==2016, vce(robust)

estimates store J

reg rep_vote pro_abortion ib2.VCF0104 i.VCF0102 i.VCF0106 ib2.VCF0110 i.VCF0114 i.VCF0870 if VCF0004==2020, vce(robust)

estimates store K

coefplot (A, label(1980)) (B, label(1984)) (C, label(1988)) (D, label(1992)) (E, label(1996)) (F, label(2000)) (G, label(2004)) (H, label(2008)) (I, label(2012)) (J, label(2016)) (K, label(2020)), keep(pro_abortion) omitted baselevels xline(0) coeflabels(pro_abortion = "Pro abortion as a predictor of Republican voting") aseq swapnames
